#coding = utf8
import time,os
import glob

FFMPEG_PATH = r'D:\ffmpeg\bin\ffmpeg.exe'
VIDEO_DIR  = 'E:/video/test'
def recording():
    # 输出视频文件
    outputfile = VIDEO_DIR  + time.strftime('%Y%m%d_%H%M%S', time.localtime()) + '.mp4'

    # 工具目录

    settings = '-y -rtbufsize 100M -f gdigrab -framerate 20 ' +\
               '-draw_mouse 1 -i desktop -c:v libx264 -r 20 ' +\
               '-crf 35 -pix_fmt yuv420p ' \
               '-fs 100M   "%s"' % outputfile

    recordingCmdLine = FFMPEG_PATH + ' ' + settings
    # 查看命令内容
    print(recordingCmdLine)

    # 执行命令录制视频
    os.system(recordingCmdLine)
recording()
